<template></template>
<script>
export default {
  mounted() {
    // 仅客户端执行
    if (process.client) {
      this.initGammaAds();
      this.initPTOAds();
    }
  },

  methods: {
    // 初始化主广告位
    initGammaAds() {
      window.gammatag?.cmd?.push(() => {
        // Mobile Underlay (640x1386)
        window.gammatag.defineZone({
          code: 'gax-inpage-async-1741749717',
          size: [640, 1386],
          params: {
            siteId: '1700816698',
            zoneId: '1741749717',
            zoneType: 'Inpage'
          }
        });

        // MR1 (300x250)
        window.gammatag.defineZone({
          code: 'gax-inpage-async-1741077142',
          size: [300, 250],
          params: {
            siteId: '1700816698',
            zoneId: '1741077142',
            zoneType: 'Inpage'
          }
        });

        // 发送广告请求
        window.gammatag.sendRequest();
      });
    },

    // 初始化 PTO 广告
    initPTOAds() {
      window._ase = window._ase || [];
      window._ase.push(['1700816698', '1700817117']);

      const script = document.createElement('script');
      script.src = 'https://ssp-cdn.gammaplatform.com/js/ad-exchange.js';
      document.body.appendChild(script);
    }
  },

  beforeDestroy() {
    // 清理广告实例
    if (process.client) {
      window.gammatag = null;
      window._ase = null;
    }
  }
};
</script>
